﻿using System;
using System.Security;
using System.Web.UI;
using NetDon.OA.Business;
using NetDon.OA.Interface;
using NetDon.Utilities;

namespace NetDon.OA.Portal
{
    using WebControls;

    public class UserControlBase : UserControl
    {
        /// <summary>
        /// 获取页面参数管理器。
        /// </summary>
        public PageParameterManager Parameters
        {
            get
            {
                return Page.Parameters;

            }
        }

        protected OrderStatus OrderStatus
        {
            set { ViewState["OrderStatus"] = value; }
            get
            {
                if (ViewState["OrderStatus"] != null)
                    return (OrderStatus)Enum.Parse(typeof(OrderStatus), ViewState["OrderStatus"].ToString());
                return OrderStatus.Submitted;
            }
        }

        protected static OApplicationContext CurrentApplicationContext
        {
            get
            {
                return ServiceContainer.GetService<ApplicationContext>() as OApplicationContext;
            }
        }
        protected new NetDonPage Page
        {
            get
            {
                var page = base.Page as NetDonPage;
                if (page==null)
                {
                    throw new VerificationException("The page must be inherit from NetDonPage.");
                }
                return page;
            }
        }
        /// <summary>
        /// 显示Alert提示信息
        /// </summary>
        /// <param name="message">提示信息内容</param>
        protected virtual void Alert(string message)
        {
            Page.Alert(message);
        }

        /// <summary>
        /// 写客户端脚本(RegisterStartupScript)
        /// </summary>
        /// <param name="scriptContent">脚本内容</param>
        /// <remarks>此方法会在页面的结尾处加入javascript脚本块，用于在页面加载完成后的客户端数据初始化</remarks>
        protected virtual void ScriptStartup(string scriptContent)
        {
            Page.ScriptStartup(scriptContent);
        }
    }
}


